package com.liug.droidsmall2.fragment;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.animation.BounceInterpolator;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.liug.droidsmall2.R;
import com.liug.droidsmall2.adapter.ForumAdapter;
import com.liug.droidsmall2.base.BaseFragment;
import com.scwang.smartrefresh.header.WaterDropHeader;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
//import com.yanzhenjie.album.Album;

/**
 * 论坛页面
 * Created by LG on 2018/7/31.
 */
public class ForumFragment extends BaseFragment {
    private RecyclerView forum_view;
    private ImageView show_show;
    private RelativeLayout menu_forum;
    private SmartRefreshLayout reswsm;

    @Override
    public void initData(Bundle savedInstanceState, Context context) {

    }

    @Override
    public void initView(View view, Context context) {

        forum_view = (RecyclerView) view.findViewById(R.id.forum_view);
        reswsm = (SmartRefreshLayout) view.findViewById(R.id.reswsm);
        show_show = (ImageView) view.findViewById(R.id.show_show);
        menu_forum = (RelativeLayout) view.findViewById(R.id.menu_forum);

        reswsm.setRefreshHeader(new WaterDropHeader(getActivity()));
        forum_view.setLayoutManager(new LinearLayoutManager(getActivity()));
        ForumAdapter forumAdapter = new ForumAdapter(context, this);
        forum_view.setAdapter(forumAdapter);

        show_show.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (menu_forum.getVisibility() == View.GONE) {
                    menu_forum.setVisibility(View.VISIBLE);

                    ObjectAnimator a1 = ObjectAnimator.ofFloat(menu_forum, "rotation", 300F, 360F);
                    a1.setInterpolator(new BounceInterpolator());
                    AnimatorSet set = new AnimatorSet();
                    set.setDuration(1000);
                    set.playTogether(a1);
                    set.start();

                } else {
                    menu_forum.setVisibility(View.GONE);
                }
            }
        });
    }

    @Override
    public int setView() {
        return R.layout.forum_fagment;
    }


}
